#include <pthread.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <signal.h>

typedef enum {
    SENSOR_TEMP,
    SENSOR_HUMIDITY,
    SENSOR_LIGHT,
    ACTUATOR_AC,
    ACTUATOR_HUMIDIFI,
    ACTUATOR_LIGHT,
} DeviceType;

typedef struct DeviceManager DeviceManager;
struct DeviceManager {
    int id;
    char name[50];
    DeviceType Type;
    float value;
    DeviceManager *next;
};

extern DeviceManager *head;
extern pthread_mutex_t log_mutex;
extern volatile sig_atomic_t keep_running;

DeviceManager* find_device_by_type(DeviceType type);
void log_int(DeviceManager *msg);
void time_change(DeviceManager *device);
void add_device(DeviceType type, const char *name);
void free_all_devices();
void *sensor_update(void *arg);
void start_thread_pool();